<?php

/**
 * 
 * 
 *
 */
class Quad_Html_Element_Styles extends Quad_MagicProperties {
	
	protected $_element;
	
  public function __construct(Quad_Html_Element $element) {
    $this->_element = $element;
  }
  
	public function __set($p,$v) {
  	$p = self::_dasherize($p);
  	return parent::__set($p,$v);
  }  
  
  public function __get($p) {
  	$p = self::_dasherize($p);
  	return parent::__get($p);
  }
  
  public function _dasherize($s) {
  	$d = preg_replace('/[A-Z]/','-$0', $s);
  	$d = strtolower($d);
  	return $d;
  }
  
  public function __toString() {  	
  	$styles = $this->getProperties();
  	$pairs = array();
  	foreach ($styles as $prop => $value) {
  		$pairs[] = "$prop:$value";
  	}
  	$out = join(';',$pairs);
  	return $out;
  }
  
}